import { Demo1Component } from './demo1/demo1.component';
import { Demo2Component } from './demo2/demo2.component';
import { Demo3Component } from './demo3/demo3.component';
import { Demo4Component } from './demo4/demo4.component';
import { Demo5Component } from './demo5/demo5.component';
import { Demo6Component } from './demo6/demo6.component';
import { Demo7Component } from './demo7/demo7.component';
import { Demo8Component } from './demo8/demo8.component';
import { Demo9Component } from './demo9/demo9.component';
import { Demo10Component } from './demo10/demo10.component';
import { Demo11Component } from './demo11/demo11.component';
import { PictureComponent } from './picture/picture.component';
import { DisabledDevComponent } from './disabled-dev/disabled-dev.component';
import { RemoveComponent } from './remove/remove.component';
import { LimitComponent } from './limit/limit.component';

export const UploadConfig = {
  location: 'Upload',
  description: `上传是将网页、文字、图片、视频等信息通过Web传送至远程服务器系统上的过程。`,
  description_en: `Uploading is the process of transferring web pages, text, pictures, videos and other information to a remote server system via the web.`,
  component: [
    {
      demo: Demo1Component,
      codePath: 'showcase/upload/demo1/demo1.component',
      demoTitle: '基础使用',
      demoTitle_en: 'Basic',
      demoDescription: '基础使用',
      demoDescription_en: 'Basic use.',
    },
    {
      demo: Demo11Component,
      codePath: 'showcase/upload/demo11/demo11.component',
      demoTitle: '尺寸大小',
      demoTitle_en: 'Size',
      demoDescription: '上传框大小',
      demoDescription_en: 'Size of the upload box.',
    },
    {
      demo: Demo2Component,
      codePath: 'showcase/upload/demo2/demo2.component',
      demoTitle: '已上传文件列表',
      demoTitle_en: 'List of Uploaded Files',
      demoDescription: '已上传文件列表',
      demoDescription_en: 'List of uploaded files.',
    },
    {
      demo: Demo3Component,
      codePath: 'showcase/upload/demo3/demo3.component',
      demoTitle: '过滤器',
      demoTitle_en: 'Filter',
      demoDescription: '使用lvFilter实现各种自定义过滤',
      demoDescription_en: 'Use lvFilter to implement various custom filters.',
    },
    {
      demo: Demo4Component,
      codePath: 'showcase/upload/demo4/demo4.component',
      demoTitle: '上传前处理',
      demoTitle_en: 'Pre-upload Processing',
      demoDescription: '上传前处理',
      demoDescription_en: 'Pre-upload processing.',
    },
    {
      demo: RemoveComponent,
      codePath: 'showcase/upload/remove/remove.component',
      demoTitle: '删除前处理',
      demoTitle_en: 'Pre-remove Processing',
      demoDescription: '删除前处理',
      demoDescription_en: 'Pre-remove processing.',
    },
    {
      demo: Demo5Component,
      codePath: 'showcase/upload/demo5/demo5.component',
      demoTitle: '上传成功前处理',
      demoTitle_en: 'Pre-successful Upload',
      demoDescription: '上传成功前处理',
      demoDescription_en: 'Pre-successful upload.',
    },
    {
      demo: Demo6Component,
      codePath: 'showcase/upload/demo6/demo6.component',
      demoTitle: '禁用',
      demoTitle_en: 'Disable',
      demoDescription: '禁用',
      demoDescription_en: 'Disable status.',
    },
    {
      demo: LimitComponent,
      codePath: 'showcase/upload/limit/limit.component',
      demoTitle: '限制',
      demoTitle_en: 'Limit',
      demoDescription: '限制上传文件大小、类型、最大文件数量。',
      demoDescription_en: 'Limit the size, type, and maximum number of files to be uploaded.',
    },
    {
      demo: DisabledDevComponent,
      codePath: 'showcase/upload/disabled-dev/disabled-dev.component',
      demoTitle: '本地开发验证禁用功能',
      demoTitle_en: 'DisabledDevDemo',
      demoDescription: '本地开发验证禁用功能',
      demoDescription_en: 'Disable status.',
      devDebug: true
    },
    {
      demo: Demo10Component,
      codePath: 'showcase/upload/demo10/demo10.component',
      demoTitle: '拖拽上传',
      demoTitle_en: 'Draggable',
      demoDescription: '把文件拖入指定区域，完成上传，同样支持点击上传。',
      demoDescription_en: 'You can drag files to a specific area, to upload. Alternatively, you can also upload by selecting.',
    },
    {
      demo: PictureComponent,
      codePath: 'showcase/upload/picture/picture.component',
      demoTitle: '照片墙',
      demoTitle_en: 'Photo wall',
      demoDescription: '上传图片并在列表中显示。',
      demoDescription_en: 'Upload images and display them in the list.',
    },
    {
      demo: Demo7Component,
      codePath: 'showcase/upload/demo7/demo7.component',
      demoTitle: '自定义上传面板',
      demoTitle_en: 'Custom Upload Panel',
      demoDescription: '自定义上传面板',
      demoDescription_en: 'Custom upload panel.',
    },
    {
      demo: Demo8Component,
      codePath: 'showcase/upload/demo8/demo8.component',
      demoTitle: '自定义上传',
      demoTitle_en: 'Custom Upload',
      demoDescription: '自定义上传',
      demoDescription_en: 'Custom upload.',
    },
    {
      demo: Demo9Component,
      codePath: 'showcase/upload/demo9/demo9.component',
      demoTitle: '手动上传',
      demoTitle_en: 'Manual Upload',
      demoDescription: '手动上传，单击”上传文件”按钮开始上传',
      demoDescription_en: 'Manual upload.',
    },
  ],
  useRule: [],
  useSuggestion: [],
  snippet: `<lv-upload (lvChange)='\${1:change($event)}' lvUrl='\${2:/sails/api/v1/upload}' lvAutoUpload lvAccept='\${3:image/jpeg,image/png}'></lv-upload>`,
  mApi: [
    {
      name: 'lv-upload',
      name_en: 'lv-upload',
      selector: 'lv-upload',
      api: [
        {
          attribute: 'lvName',
          type: 'string',
          default: 'file',
          description: `用于标识后端文件的请求参数的名称`,
          description_en: `The name of the request parameter used to identify the backstage file.`,
        },
        {
          attribute: 'lvSize',
          type: 'default | large',
          default: 'default',
          description: `上传框大小，仅 lvType 为 select 时生效`,
          description_en: `Size of the upload box. This parameter is valid only when lvType is set to select.`,
        },
        {
          attribute: 'lvPlaceholder',
          type: 'string',
          default: '请选择文件',
          description: `占位符`,
          description_en: `placeholder.`,
        },
        {
          attribute: 'lvUrl',
          type: 'string',
          default: '',
          description: `上传地址`,
          description_en: `Upload address.`,
        },
        {
          attribute: 'lvMethod',
          type: 'string',
          default: 'post',
          description: `上传方式`,
          description_en: `Upload method.`,
        },
        {
          attribute: 'lvData',
          type: '{[key: string]: any} | ((file: UploadFile) => {[key: string]: any})',
          default: '{}',
          description: `上传所需参数`,
          description_en: `Upload required parameters.`,
        },
        {
          attribute: 'lvFiles',
          type: 'UploadFile[]',
          default: '[]',
          description: `
      文件列表的源数据，双向绑定。UploadFile 属性如下：
        <ul>
          <li>[key: string] 文件的关键key，具有唯一性 (必选)</li>
          <li>[name: string] 显示的文件名称 (必选)</li>
          <li>[size: number] 文件大小 (必选)</li>
          <li>[fileSize: string] 格式化后的文件大小，带单位 (可选)</li>
          <li>[type: string] 文件类型 (必选)</li>
          <li>[lastModified: number]  最近一次的修改时间，时间戳格式(可选)</li>
          <li>[lastModifiedDate: Date]  最近一次的修改时间，日期格式(可选)</li>
          <li>[status: UploadFileStatusEnum] 上传状态，select | ready | progress | success | error | cancel | remove(可选)</li>
          <li>[progress: number] 上传进度 (可选)</li>
          <li>[response: any] 上传成功返回结果 (可选)</li>
          <li>[error: any] 上传失败返回结果 (可选)</li>
          <li>[errorTip: string] 上传失败原因提示信息 (可选)</li>
          <li>[originFile: File] 文件对象 (可选)</li>
        </ul>
      `,
          description_en: `
      File list, two-way binding. The UploadFile properties are as follows:
        <ul>
          <li>[key: string] The key key of the file, unique (required)</li>
          <li>[name: string] Displayed file name (required)</li>
          <li>[size: number] File size (required)</li>
          <li>[fileSize: string] Formatted file size, with unit (optional)</li>
          <li>[type: string] File type (required)</li>
          <li>[lastModified: number]  Last modification time, timestamp format.(optional)</li>
          <li>[lastModifiedDate: Date]  Last modification time, date format.(optional)</li>
          <li>[status: UploadFileStatusEnum] Upload Status,select | ready | progress | success | error | cancel | remove (optional)</li>
          <li>[progress: number] Upload progress (optional)</li>
          <li>[response: any] Upload success result  (optional)</li>
          <li>[error: any] Upload failure result (optional)</li>
          <li>[errorTip: string] upload failure tip (optional)</li>
          <li>[originFile: File] File Object (optional)</li>
        </ul>
      `,
        },
        {
          attribute: 'lvAccept',
          type: 'string',
          default: '*',
          description: `接受的文件类型, 默认全部`,
          description_en: `Accepted file type, default all.`,
        },
        {
          attribute: 'lvAllowFileSuffix',
          type: 'string',
          default: '',
          description: `允许上传的文件后缀，在绕过accept可增加使用;以,分割`,
          description_en: `Allow file suffixes to be uploaded, bypassing accept to increase usage; ','segment`,
        },
        {
          attribute: 'lvMultiple',
          type: 'boolean',
          default: 'false',
          description: `是否支持多文件上传`,
          description_en: `Whether to support multiple file uploads.`,
        },
        {
          attribute: 'lvDisabled',
          type: 'boolean',
          default: 'false',
          description: `是否禁用`,
          description_en: `Whether to disable?`,
        },
        {
          attribute: 'lvAutoUpload',
          type: 'boolean',
          default: 'false',
          description: `是否自动上传`,
          description_en: `Whether to upload automatically?`,
        },
        {
          attribute: 'lvMaxFileSize',
          type: 'number',
          default: '0',
          description: `允许上传单个文件最大大小，0表示不限`,
          description_en: `Allow uploading the maximum size of a single file, 0 means no limit.`,
        },
        {
          attribute: 'lvMaxFileUnit',
          type: 'UploadUnitEnum',
          default: 'UploadUnitEnum.BYTE',
          description: `允许上传单个文件最大大小的单位,默认B`,
          description_en: `Unit of the maximum size of a file that can be uploaded. The default value is B.`,
        },
        {
          attribute: 'lvFileLimit',
          type: 'number',
          default: '0',
          description: `最大可上传文件个数，lvMultiple为true时有效，0表示不限`,
          description_en: `The maximum number of files that can be uploaded,This parameter is valid only when lvMultiple is set to true, 0 means no limit.`,
        },
        {
          attribute: 'lvCustomUpload',
          type: '(options: UploadHttpRequestOptions) => Observable<any>',
          default: '',
          description: `自定义上传方法`,
          description_en: `Custom upload method.`,
        },
        {
          attribute: 'lvConcurrentNumber',
          type: 'number',
          default: '0',
          description: `限制单次上传最多并发数，0表示不限`,
          description_en: `Limit the maximum number of concurrent uploads, 0 means no limit.`,
        },
        {
          attribute: 'lvHeaders',
          type: '{[key: string]: any} | ((file: UploadFile) => {[key: string]: any})',
          default: '{}',
          description: `设置请求头`,
          description_en: `Set request header.`,
        },
        {
          attribute: 'lvType',
          type: 'select | drag | picture',
          default: 'select',
          description: `上传类型：选择、拖拽、图片，默认选择`,
          description_en: `Upload type: select, drag, picture, default select`,
        },
        {
          attribute: 'lvContentTemplate',
          type: 'TemplateRef<{ $implicit: any }>',
          default: '',
          description: `自定义上传面板`,
          description_en: `Custom upload panel`,
        },
        {
          attribute: 'lvMultiple',
          type: 'boolean',
          default: 'false',
          description: `是否支持多文件上传`,
          description_en: `Whether to support multiple file uploads?`,
        },
        {
          attribute: 'lvFilters',
          type: 'UploadFilter[]',
          default: '[]',
          description: `自定义过滤规则`,
          description_en: `Custom filter rules.`,
        },
        {
          attribute: 'lvUploadErrorMessage',
          type: 'string',
          default: '',
          description: `上传错误信息，多用于表单的错误校验`,
          description_en: `Upload error information, which is mainly used for form error verification.`,
        },
        {
          attribute: 'lvShowReupload',
          type: 'boolean',
          default: 'true',
          description: `是否支持单个重试按钮`,
          description_en: `Whether to support a single retry button?`,
        },
        {
          attribute: 'lvShowCancel',
          type: 'boolean',
          default: 'true',
          description: `是否支持取消上传按钮`,
          description_en: `Whether to support the cancel upload button?`,
        },
        {
          attribute: 'lvShowUpload',
          type: 'boolean',
          default: 'true',
          description: `是否显示上传按钮，如果配置了自动上传此配置无用`,
          description_en: `Whether to display the upload button, this configuration is useless if auto upload is configured`,
        },
        {
          attribute: 'lvHelpText',
          type: 'boolean | string | TemplateRef',
          default: 'false',
          description: `是否支持显示传入的帮助文本，仅 lvType 为 drag 类型时生效`,
          description_en: `Whether to display the input help text. This parameter is valid only when lvType is set to drag.`,
        },
        {
          attribute: 'lvExtra',
          type: 'string | TemplateRef',
          default: '',
          description: `上传列表右侧的扩展内容。`,
          description_en: `Extended content on the right of the upload list.`,
        },
        {
          attribute: 'lvBeforeUpload',
          type: '(file: UploadFile, fileList: UploadFile[]) => boolean | void | Observable<boolean>',
          default: '',
          description: `上传文件之前的钩子，若返回false停止上传`,
          description_en: `The hook before uploading the file, if it returns false, stop uploading.`,
        },
        {
          attribute: 'lvBeforeSuccess',
          type: '(response: HttpResponse<any>, file: UploadFile) => boolean | void | Observable<boolean>',
          default: '',
          description: `文件上传成功之前的钩子，若返回false则上传失败`,
          description_en: `The hook before the file upload succeeds, if it returns false, the upload fails.`,
        },
        {
          attribute: 'lvCustomHttpRequest',
          type: '{[key: string]: any} | ((file: UploadFile) => {[key: string]: any})',
          default: '',
          description: `自定义设置上传请求的参数，独立单项配置优先级高于当前配置`,
          description_en: `Set upload request parameters. Independent configuration takes precedence over the current configuration.`,
        },
      ],
      event: [
        {
          event: 'lvFilesChange',
          parameter: ``,
          description: 'files列表变更回调',
          description_en: 'Files list change callback.',
        },
        {
          event: 'lvChange',
          parameter: ``,
          description: '选择文件、上传、成功、失败变化的回调',
          description_en: 'Select file, upload, success, failure callbacks.',
        },
      ],
    },
  ],
};

